#ifndef SERVERUDP_HPP_
# define SERVERUDP_HPP_

#include "iostream"
#include "string.h"
#include "string"
#include "stdlib.h"

#include "Buffer.hpp"
#include "TimeVal.hpp"
#include "Control.hpp"
#include "FdInfos.hpp"
#include "IAUdp.hpp"
#include "UdpUnix.hpp"

class ServerUdp
{
  IAUdp	*Udp;
  FdInfos	FdInfo;
  TimeVal	Tim;
  int	Port;
  char WriteBuf[1024];
  char	ReadBuf[1024];
  int	FdSocketSend;
  int	FdSocketRecv;
  SockInfo SinSource;
  SockInfo SinTargetRcv;
  SockInfo SinTargetSend;
  
  int SendToOrRecvFrom();
  int AddWrite(char *buff,
	       int sizeBuf);

public:
  ServerUdp(int port);
  ~ServerUdp();

  int Run();
};

template <typename T>
T	to(const std::string    &str)
{
  std::istringstream	iss(str);
  T			i;

  iss >> i;
  return (i);
}


#endif /*SERVERUDP_HPP_*/
